<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" th:href="@{/css/font.css}">
    <link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <script type="text/javascript" th:src="@{/js/ztree/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
</head>

<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>用户名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="username" name="username"  lay-verify="required" readonly="readonly" th:value="${SALES_EDIT.getUsername()}"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                用户名不能改变
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>密码
            </label>
            <div class="layui-input-inline">
                <input type="text" id="password" name="password"  lay-verify="required" th:value="${SALES_EDIT.password}"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>姓名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="name" name="name" lay-verify="password" th:value="${SALES_EDIT.getName()}"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                显示的姓名
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button class="layui-btn" lay-filter="add" lay-submit id="submitEdit">
                提交
            </button>
        </div>
    </form>
</div>
<script>

    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;

        form.on('submit(add)', function (data) {
            // console.log(data);
            let username = $("#username").val();
            let name = $("#name").val();
            let password = $("#password").val();
            // let status = $("#status").val();
            // let wares_mark = $("#wares_mark").val();
            // 发异步，把数据提交给后台
            $.ajax({
                url: "/sales/modifySalesMessage",
                type: "PUT",
                data:{
                    username:username,
                    name:name,
                    password: password,
                },
                success: function (resultInfo) {
                    if(resultInfo.flag){
                        layer.alert(resultInfo.message, {icon: 6}, function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                        });
                    }else {
                        layer.alert(resultInfo.message, {icon: 5}, function () {
                        });
                    }
                },error:function (e) {
                    // console.log("这里出现了问题！");
                    // console.log(e);
                }

            });
            return false;
        })

    });

</script>
</body>

</html>